$(function () {
    var eid = GetQueryString("eid");
    var meetNum = GetQueryString("meetNum");
    var type = GetQueryString("type");
    var sel = $.Params.create();
    sel.ajax("get", getAdminIP() + "pfMembers/" + eid, function (data) {
        if (data.success) {
            var val = data.result;
            $("#name").val(val.name);
            $("#tel").val(val.tel);
            $("#hospitalName").val(val.hospitalName);
        } else {
            alert(data.msg);
        }
    })



    $("#addData").on("click", function () {
        var name = $("#name").val();
        var tel = $("#tel").val();
        var hospitalName = $("#hospitalName").val();
        if (name == "") {
            alert("姓名不能为空！");
            return false;
        }
        if (!(valPhone(tel))) {
            alert("手机格式不正确！");
            return false;
        }
        if (hospitalName == "") {
            alert("医院不能为空！");
            return false;
        }
        var addSel = $.Params.create();
        addSel.addParams("name", name);
        addSel.addParams("tel", tel);
        addSel.addParams("hospitalName", hospitalName);
        addSel.ajax("put", getAdminIP() + "pfMembers/" + eid, function (data) {
            if (data.success) {
                if (type == "1") {
                    window.location.href = "pfMemberJudgeList.html?meetNum=" + meetNum + "&type=" + type;
                } else if (type == "2") {
                    window.location.href = "pfMemberPlayerList.html?meetNum=" + meetNum + "&type=" + type;
                }
            } else {
                alert(data.msg);
            }
        })
    })
    $("#cancelAdd").on("click", function () {
        history.go(-1);
    })
})